<template>
  <div id="strategyEdit">
    <mt-header fixed title="编辑" v-if="isHeader">
      <mt-button icon="back" slot="left" @click="goBack"></mt-button>
      <!--<mt-button slot="right" @click="delStragy">-->
      <!--<i class="fa fa-trash-o go-btn" aria-hidden="true"></i>-->
      <!--</mt-button>-->
    </mt-header>
    <div class="strategyEdit-cont" :class="isHeader?'isHeader':''">
      <div class="strategyEdit-title">
        <div class="item-l">
          <span class="">策略名称</span>
        </div>
        <div class="item-r">
          <span class="btn-rev">重命名</span>
          <span class="btn-del">删除</span>
        </div>
      </div>
      <div class="strategyEdit-list">
        <div class="strategyEdit-list-item" v-for="(s, index) in options" :key="index">
          <div class="item-l" @click="checkItem(s)">
            <!--<i class="el-icon-circle-check" :class="s.isSelect?'bg_sel':'bg_org'"></i>-->
            <i class="btn-circle"></i>
            <span class="text-name">{{s.strategy_name}}</span>
          </div>
          <div class="item-r">
            <span class="btn-rev" @click="reName(s)">
               <i class="el-icon-edit-outline"></i>
            </span>
            <span class="btn-del" @click="delStragy(s)">
               <i class="fa fa-trash-o go-btn" aria-hidden="true"></i>
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import REQUEST from './../services/test'

  export default {
    name: 'strategyEdit',
    data () {
      return {
        isHeader: false,
        value: [],
        options: []
      }
    },
    created () {
      this.$store.commit('getUrlParams')
      this.isHeader = this.$store.state.isHeader
      this.getMyStrategys()
    },
    methods: {
      goBack: function () {
        // history.back()
        this.$router.go(-1)
        // this.$router.push({path: '/myStrategyMore'})
      },
      checkItem (_item) {
        _item.isSelect = !_item.isSelect
      },
      delStragy (_item) {
        let userInfo = this.$store.state.userInfo
        let _self = this
        REQUEST.delMyStrategys(userInfo, _item).then(res => {
          if (res) {
            _self.getMyStrategys()
          }
        }).catch(err => {
          console.info(err)
        })
      },
      getMyStrategys () {
        let userInfo = this.$store.state.userInfo
        let _self = this
        REQUEST.allMyStrategys(userInfo).then(res => {
          // console.log('所有策略',res)
          res.forEach((v, k) => {
            v.isSelect = false
          })
          _self.options = res
        }).catch(err => {
          console.info(err)
        })
      },
      reName (s) {
        this.$router.push({path: '/reStrategyName', query: s})
      }
    },
    computed: {
      test () {
        let opt = this.options
        return opt
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
  #strategyEdit {
    .mint-header.is-fixed {
      background-color: #0f1316;
    }
    .strategyEdit-cont.isHeader {
      margin-top: 1.25rem !important;
    }
    .strategyEdit-cont {
      /*margin-top: 1.25rem;*/
      background: #ffffff;
      .strategyEdit-title {
        height: 1rem;
        line-height: 1rem;
        color: #666666;
        font-size: 0.3733333rem;
        border-bottom: 1px solid #e5e5e5;
        display: box;
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        .item-l {
          -webkit-box-flex: 1;
          -moz-box-flex: 1;
          /*width: 20%;*/
          -webkit-flex: 1;
          -ms-flex: 1;
          flex: 1;
          text-align: left;
          display: box;
          display: -webkit-box;
          display: -moz-box;
          display: -ms-flexbox;
          display: -webkit-flex;
          display: flex;
          -webkit-box-align: center;
          -webkit-align-items: center;
          -moz-align-items: center;
          -ms-align-items: center;
          -o-align-items: center;
          align-items: center;
          span {
            margin-left: 0.2666667rem;
            white-space: nowrap;
            overflow: hidden;
          }
        }
        .item-r {
          -webkit-box-flex: 1;
          -moz-box-flex: 1;
          /*width: 20%;*/
          -webkit-flex: 1;
          -ms-flex: 1;
          flex: 1;
          text-align: right;
          /*padding-right: 0.5333333rem;*/
          padding-right: 0.2666667rem;
          .btn-rev {
            padding: 0.0533333rem;
          }
          .btn-del {
            padding: 0.0533333rem;
          }
        }
      }
      .strategyEdit-list {
        .strategyEdit-list-item {
          /*text-align: left;*/
          padding-left: 0.2666667rem;
          height: 1.2rem;
          line-height: 1.2rem;
          display: box;
          display: -webkit-box;
          display: -moz-box;
          display: -ms-flexbox;
          display: -webkit-flex;
          display: flex;
          .item-l {
            -webkit-box-flex: 1;
            -moz-box-flex: 1;
            /*width: 20%;*/
            -webkit-flex: 1;
            -ms-flex: 1;
            flex: 1;
            text-align: left;
            display: box;
            display: -webkit-box;
            display: -moz-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -moz-align-items: center;
            -ms-align-items: center;
            -o-align-items: center;
            align-items: center;
            .btn-circle {
              display: block;
              height: 0.2666667rem;
              width: 0.2666667rem;
              background: #1296db;
              border-radius: 50%;
            }
            .text-name {
              margin-left: 0.2666667rem;
              white-space: nowrap;
              overflow: hidden;
            }
          }
          .item-r {
            -webkit-box-flex: 1;
            -moz-box-flex: 1;
            /*width: 20%;*/
            -webkit-flex: 1;
            -ms-flex: 1;
            flex: 1;
            text-align: right;
            padding-right: 0.5333333rem;
            color: #cccccc;
            .btn-rev {
              padding: 0.1066667rem;
            }
            .btn-del {
              padding: 0.1066667rem;
            }
          }
          i {
            font-size: 0.48rem;
          }
          span {
            font-size: 0.4rem;
          }
        }
      }
      .bg_sel {
        color: #1296db;
        border: 1px solid #1296db;
        border-radius: 50%;
      }
      .bg_org {
        color: #ffffff;
        border-radius: 50%;
        border: 1px solid #1296db;
      }
    }
  }
</style>
